package com.foodplus.www.presenter;

import com.foodplus.www.api.BaseSubscriber;
import com.foodplus.www.api.ExceptionHandle;
import com.foodplus.www.bean.basket.BasketGoodNumBean;
import com.foodplus.www.model.impl.BasketModelImpl;
import com.foodplus.www.view.impl.BasketView;

import java.util.Map;

/**
 * Created by WangZhiChao on 2016/11/2.
 */

public class BasketGoodNumPresenter {

    BasketView view;

    public BasketGoodNumPresenter(BasketView view) {
        this.view = view;
    }

    public void getBasketGoodNum(Map<String, String> params, final String cartId) {
        new BasketModelImpl().getBasketGoodNumData(params, new BaseSubscriber<BasketGoodNumBean>() {
            @Override
            public void onSuccess(BasketGoodNumBean basketBean) {

                basketBean.getDatas().setCartId(cartId);
                view.onChangeNum(basketBean);
            }

            @Override
            public void onFail(ExceptionHandle.ResponeThrowable e) {
                view.onFail(e);
            }

            @Override
            public void onFinished() {
                view.onFinish();
            }
        });
    }
}
